<template>
    <div>
      <el-select v-model="value" placeholder="请选择" @change="change">
        <el-option
          v-for="(item,index) in options"
          :key="index"
          :label="item[label]"
          :clearable="clearfalg"
          :value="index">
        </el-option>
      </el-select>
    </div>
</template>

<script>
    export default {
        name: "selectTool",
       data(){
          return{
            value:'',
            clearfalg:false
          }
       },
      methods:{
        change(index){
          this.$emit("selectedindex",index)
        },
        listenFather(){
          let that = this

          this.$on('clearselect',res=>{
            console.log(res)
            that.value = ''
          })
        },
        init(){
          this.value = ''
        }
      },
      mounted(){
        this.listenFather(),
        this.init()
      },
      created(){
        this.init()
      },
      props:[
        'options',
        'label',

      ]
    }
</script>

<style scoped>

</style>
